package com.qidian.permission.util;

/**
 * @Author 32郗建狄
 * @Company GX631
 * Time 2023/10/18 17:09
 * Description
 */
public class PerResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public PerResult() {
    }

    public PerResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static PerResult updateIsOk(int result){
        return result > 0?ok():fail();
    };

    public static PerResult ok(){
        return new PerResult(Constant.RESULT_OK,null,null);
    }
    public static PerResult ok(int code){
        return new PerResult(code,null,null);
    }
    public static PerResult ok(String msg){
        return new PerResult(Constant.RESULT_OK,msg,null);
    }
    public static PerResult ok(Object data){
        return new PerResult(Constant.RESULT_OK,"",data);
    }
    public static PerResult ok(String msg,Object data){
        return new PerResult(Constant.RESULT_OK,msg,data);
    }

    public static PerResult fail(){
        return new PerResult(Constant.RESULT_FAIL,null,null);
    }
    public static PerResult fail(int code){
        return new PerResult(code,null,null);
    }
    public static PerResult fail(String msg){
        return new PerResult(Constant.RESULT_FAIL,msg,null);
    }
    public static PerResult fail(Object data){
        return new PerResult(Constant.RESULT_FAIL,"",data);
    }
    public static PerResult fail(String msg,Object data){
        return new PerResult(Constant.RESULT_FAIL,msg,data);
    }

    public static PerResult empty(){
        return new PerResult(Constant.RESULT_EMPTY
                ,null,null);
    }
    public static PerResult empty(int code){
        return new PerResult(code,null,null);
    }
    public static PerResult empty(String msg){
        return new PerResult(Constant.RESULT_EMPTY,msg,null);
    }
    public static PerResult empty(Object data){
        return new PerResult(Constant.RESULT_EMPTY,"",data);
    }
    public static PerResult empty(String msg,Object data){
        return new PerResult(Constant.RESULT_EMPTY,msg,data);
    }


    public static PerResult duplicate(){
        return new PerResult(Constant.RESULT_DUPLICATE
                ,null,null);
    }
    public static PerResult duplicate(int code){
        return new PerResult(code,null,null);
    }
    public static PerResult duplicate(String msg){
        return new PerResult(Constant.RESULT_DUPLICATE,msg,null);
    }
    public static PerResult duplicate(Object data){
        return new PerResult(Constant.RESULT_DUPLICATE,"",data);
    }
    public static PerResult duplicate(String msg,Object data){
        return new PerResult(Constant.RESULT_DUPLICATE,msg,data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
